
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Hibernate-Validator - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Hibernate-Validator - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">Hibernate-Validator框架的核心作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Hibernate-Validator是一个数据校验框架，其主要作用是将数据校验逻辑从业务代码中分离出来，从而提高代码的可读性，并使数据校验的实现过程更加方便和简单。</div>
          </div>
          <div class="card-source">来源: 1.Hibernate-Validator 简介</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在Spring Boot项目中，如何为处理POST请求的方法启用对请求体（RequestBody）的校验？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">需要在Controller方法的参数前加上`@Valid`注解，该参数通常也带有`@RequestBody`注解，以表示需要对传入的请求体对象进行校验。</div>
          </div>
          <div class="card-source">来源: 5. POST方法中应用</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在处理GET请求时，如何对方法的参数进行校验？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">需要在Controller类上添加`@Validated`注解，然后在对应方法的参数前直接添加具体的校验注解，例如`@NotBlank`。</div>
          </div>
          <div class="card-source">来源: 6. GET方法中应用</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">当默认的校验失败信息过于冗长时，文档推荐了哪种方法来返回更优雅、统一的错误信息？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过定义一个全局异常处理器（使用`@ControllerAdvice`），捕获特定的校验异常（如`MethodArgumentNotValidException`），然后从中提取关键的错误信息，并封装成自定义的、只包含状态码和失败原因的返回格式。</div>
          </div>
          <div class="card-source">来源: 7.定义优雅的返回信息</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Hibernate-Validator支持哪两种校验模式？它们的区别是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">支持普通模式（Normal Mode）和快速失败返回模式（Fail-Fast Mode）。普通模式是默认的，它会校验完所有属性后返回全部的失败信息。而快速失败返回模式则是在遇到第一个校验失败时就立即返回，不再继续校验其他属性。</div>
          </div>
          <div class="card-source">来源: 9.Hibernate-Validator校验模式</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">如何配置并开启Hibernate-Validator的“快速失败返回模式”？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过创建一个`Validator`类型的Bean，在配置中将`hibernate.validator.fail_fast`属性设置为`"true"`来开启快速失败返回模式。</div>
          </div>
          <div class="card-source">来源: 9.Hibernate-Validator校验模式 - 开启快速失败返回模式</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">文档中是如何区分`@NotEmpty`、`@NotBlank`和`@NotNull`这三个注解的使用场景的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`@NotEmpty`用于集合类；`@NotBlank`用于String类型，它会检查null和空字符串（""）；`@NotNull`用于任何对象类型，但它只检查对象是否为null。</div>
          </div>
          <div class="card-source">来源: 8.常用注解 - 注意</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">如何实现对象间的级联校验，即校验一个对象中包含的另一个自定义对象？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在父类对象的属性字段上，除了定义其本身的校验规则外，还需要额外添加`@Valid`注解，这样Hibernate-Validator就会对该字段引用的嵌套对象进行级联校验。</div>
          </div>
          <div class="card-source">来源: 10.对象级联校验</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在普通校验模式下，对POST请求体进行校验失败时，全局异常处理器应该捕获哪种类型的异常？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在普通模式下，校验失败会抛出`MethodArgumentNotValidException`异常，因此全局异常处理器需要捕获此异常以进行自定义处理。</div>
          </div>
          <div class="card-source">来源: 7.1 定义全局异常处理</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
